package com.tech.koufu.model;

import org.json.JSONObject;

import com.tech.koufu.tools.KouFuTools;

import android.os.Parcel;
import android.os.Parcelable;

public class StockInfo implements Parcelable,Comparable<StockInfo>{
	String code;	//代码
	String name;	//简称
	String zsp;	//昨收盘
	String jkp;	//今开盘
	String cje;	//成交额
	String zg;	//最高价
	String zd;	//最低价
	String zx;	//最新价
	String bj1;	//买入价1
	String sj1;	//卖出价1
	String cjl;	//成交量
	String syl;	//市盈率
	String bl1;	//买入量1
	String bj2;	//买入价2
	String bl2;	//买入量2
	String bj3;	//买入价3
	String bl3;	//买入量3
	String sl1;	//卖出量1
	String sj2; //卖出价2
	String sl2;	//卖出量2
	String sj3;	//卖出价3
	String sl3;	//买入量3
	String bj4;	//买入价4
	String bl4;	//买入量4
	String bj5;	//买入价5
	String bl5;	//买入量5
	String sj4;	//卖出价4
	String sl4;	//卖出量4
	String sj5;	//卖出价5
	String sl5;	//卖出量5 
	String ncode; 
	//----------委托相关
	public String wtCode;
	public String entrustBs;
	public String entrustTime;
	public String cjPrice;
	public String cjTime;
	public String status;
	@Override
	public String toString() {
		return "StockInfo [code=" + code + ", name=" + name + ", zsp=" + zsp
				+ ", jkp=" + jkp + ", cje=" + cje + ", zg=" + zg + ", zd=" + zd
				+ ", zx=" + zx + ", bj1=" + bj1 + ", sj1=" + sj1 + ", cjl="
				+ cjl + ", syl=" + syl + ", bl1=" + bl1 + ", bj2=" + bj2
				+ ", bl2=" + bl2 + ", bj3=" + bj3 + ", bl3=" + bl3 + ", sl1="
				+ sl1 + ", sj2=" + sj2 + ", sl2=" + sl2 + ", sj3=" + sj3
				+ ", sl3=" + sl3 + ", bj4=" + bj4 + ", bl4=" + bl4 + ", bj5="
				+ bj5 + ", bl5=" + bl5 + ", sj4=" + sj4 + ", sl4=" + sl4
				+ ", sj5=" + sj5 + ", sl5=" + sl5 + "]";
	}

	public StockInfo() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	 

	public StockInfo(String code, String name, String zsp, String jkp,
			String cje, String zg, String zd, String zx, String bj1,
			String sj1, String cjl, String syl, String bl1, String bj2,
			String bl2, String bj3, String bl3, String sl1, String sj2,
			String sl2, String sj3, String sl3, String bj4, String bl4,
			String bj5, String bl5, String sj4, String sl4, String sj5,
			String sl5 ) {
		super();
		this.code = code;
		this.name = name;
		this.zsp = zsp;
		this.jkp = jkp;
		this.cje = cje;
		this.zg = zg;
		this.zd = zd;
		this.zx = zx;
		this.bj1 = bj1;
		this.sj1 = sj1;
		this.cjl = cjl;
		this.syl = syl;
		this.bl1 = bl1;
		this.bj2 = bj2;
		this.bl2 = bl2;
		this.bj3 = bj3;
		this.bl3 = bl3;
		this.sl1 = sl1;
		this.sj2 = sj2;
		this.sl2 = sl2;
		this.sj3 = sj3;
		this.sl3 = sl3;
		this.bj4 = bj4;
		this.bl4 = bl4;
		this.bj5 = bj5;
		this.bl5 = bl5;
		this.sj4 = sj4;
		this.sl4 = sl4;
		this.sj5 = sj5;
		this.sl5 = sl5;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getZsp() {
		return zsp;
	}

	public void setZsp(String zsp) {
		this.zsp = zsp;
	}

	public String getJkp() {
		return jkp;
	}

	public void setJkp(String jkp) {
		this.jkp = jkp;
	}

	public String getCje() {
		return cje;
	}

	public void setCje(String cje) {
		this.cje = cje;
	}

	public String getZg() {
		return zg;
	}

	public void setZg(String zg) {
		this.zg = zg;
	}

	public String getZd() {
		return zd;
	}

	public void setZd(String zd) {
		this.zd = zd;
	}

	public String getZx() {
		return zx;
	}

	public void setZx(String zx) {
		this.zx = zx;
	}

	public String getBj1() {
		return bj1;
	}

	public void setBj1(String bj1) {
		this.bj1 = bj1;
	}

	public String getSj1() {
		return sj1;
	}

	public void setSj1(String sj1) {
		this.sj1 = sj1;
	}

	public String getCjl() {
		return cjl;
	}

	public void setCjl(String cjl) {
		this.cjl = cjl;
	}

	public String getSyl() {
		return syl;
	}

	public void setSyl(String syl) {
		this.syl = syl;
	}

	public String getBl1() {
		return bl1;
	}

	public void setBl1(String bl1) {
		this.bl1 = bl1;
	}

	public String getBj2() {
		return bj2;
	}

	public void setBj2(String bj2) {
		this.bj2 = bj2;
	}

	public String getBl2() {
		return bl2;
	}

	public void setBl2(String bl2) {
		this.bl2 = bl2;
	}

	public String getBj3() {
		return bj3;
	}

	public void setBj3(String bj3) {
		this.bj3 = bj3;
	}

	public String getBl3() {
		return bl3;
	}

	public void setBl3(String bl3) {
		this.bl3 = bl3;
	}

	public String getSl1() {
		return sl1;
	}

	public void setSl1(String sl1) {
		this.sl1 = sl1;
	}

	public String getSj2() {
		return sj2;
	}

	public void setSj2(String sj2) {
		this.sj2 = sj2;
	}

	public String getSl2() {
		return sl2;
	}

	public void setSl2(String sl2) {
		this.sl2 = sl2;
	}

	public String getSj3() {
		return sj3;
	}

	public void setSj3(String sj3) {
		this.sj3 = sj3;
	}

	public String getSl3() {
		return sl3;
	}

	public void setSl3(String sl3) {
		this.sl3 = sl3;
	}

	public String getBj4() {
		return bj4;
	}

	public void setBj4(String bj4) {
		this.bj4 = bj4;
	}

	public String getBl4() {
		return bl4;
	}

	public void setBl4(String bl4) {
		this.bl4 = bl4;
	}

	public String getBj5() {
		return bj5;
	}

	public void setBj5(String bj5) {
		this.bj5 = bj5;
	}

	public String getBl5() {
		return bl5;
	}

	public void setBl5(String bl5) {
		this.bl5 = bl5;
	}

	public String getSj4() {
		return sj4;
	}

	public void setSj4(String sj4) {
		this.sj4 = sj4;
	}

	public String getSl4() {
		return sl4;
	}

	public void setSl4(String sl4) {
		this.sl4 = sl4;
	}

	public String getSj5() {
		return sj5;
	}

	public void setSj5(String sj5) {
		this.sj5 = sj5;
	}

	public String getSl5() {
		return sl5;
	}

	public void setSl5(String sl5) {
		this.sl5 = sl5;
	}

	@Override
	public int describeContents() { 
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) { 
		dest.writeString(code);
		dest.writeString(name);
		dest.writeString(zsp);
		dest.writeString(jkp);
		dest.writeString(cje);
		dest.writeString(zg);
		
		dest.writeString(zd);
		dest.writeString(zx);
		dest.writeString(bj1);
		dest.writeString(sj1);
		dest.writeString(cjl);
		dest.writeString(syl);
		
		dest.writeString(bl1);
		dest.writeString(bj2);
		dest.writeString(bl2);
		dest.writeString(bj3);
		dest.writeString(bl3);
		dest.writeString(sl1);
		
		dest.writeString(sj2);
		dest.writeString(sl2);
		dest.writeString(sj3);
		dest.writeString(sl3);
		dest.writeString(bj4);
		dest.writeString(bl4);
		dest.writeString(bj5);
		dest.writeString(bl5);
		
		dest.writeString(sj4);
		dest.writeString(sl4);
		dest.writeString(sj5);
		dest.writeString(sl5); 
		
		dest.writeString(wtCode);
		dest.writeString(entrustBs);
		dest.writeString(entrustTime);
		dest.writeString(cjPrice);
		dest.writeString(cjTime);
		dest.writeString(status);
	}
	
	public StockInfo(Parcel source){
		this.code = source.readString();
		this.name = source.readString();
		this.zsp = source.readString();
		this.jkp = source.readString();
		this.cje = source.readString();
		this.zg = source.readString();
		this.zd = source.readString();
		this.zx = source.readString();
		this.bj1 = source.readString();
		this.sj1 = source.readString();
		this.cjl = source.readString();
		this.syl = source.readString();
		this.bl1 = source.readString();
		this.bj2 = source.readString();
		this.bl2 = source.readString();
		this.bj3 = source.readString();
		this.bl3 = source.readString();
		this.sl1 = source.readString();
		this.sj2 = source.readString();
		this.sl2 = source.readString();
		this.sj3 = source.readString();
		this.sl3 = source.readString();
		this.bj4 = source.readString();
		this.bl4 = source.readString();
		this.bj5 = source.readString();
		this.bl5 = source.readString();
		this.sj4 = source.readString();
		this.sl4 = source.readString();
		this.sj5 = source.readString();
		this.sl5 = source.readString();
		this.wtCode = source.readString();
		this.entrustBs = source.readString();
		this.entrustTime = source.readString();
		this.cjPrice = source.readString();
		this.cjTime = source.readString();
		this.status = source.readString();
	}
	public static final Parcelable.Creator<StockInfo> CREATOR = new Creator<StockInfo>() {

		@Override
		public StockInfo createFromParcel(Parcel source) { 
			return new StockInfo(source);
		}

		@Override
		public StockInfo[] newArray(int size) { 
			return new StockInfo[size];
		}
	};
	
	/**
	 * 
	* @Title: getStocksMarketsValue 
	* @Description: TODO(得到) 
	* @param @param zx 当前价
	* @param @param zsp 以前收盘价
	* @param @return    result[0]=1 :涨幅 0为跌幅
	* @return float    返回类型 
	* @throws
	 */
	public  String[] getStocksMarketsValue(String pZx ,String pZsp){
		String[] result = new String[2];
		if(pZx==null){
			pZx = this.zx;
		}
		if(pZsp == null){
			pZsp = this.zsp;
		}
		float fZx= Float.valueOf(pZx);
		float fzsp = Float.valueOf(pZsp);
		if(fZx>fzsp){
			result[0] = "1";
			result[1] = KouFuTools.df3.format((fZx-fzsp)/fzsp*100);
		}else if(fZx< fzsp){
			result[0] = "0";
			result[1] = KouFuTools.df3.format((fZx-fzsp)/fZx*100);
		}else{
			result[0] = "0";
			result[1] = "0";
		}
		
		return result;
	}
	public  String getNstocksMarketsValue(String pZx ,String pZsp){
		float fZx= Float.valueOf(pZx);
		float fzsp = Float.valueOf(pZsp);
		return KouFuTools.df2.format((fZx-fzsp)/fZx*100);
	}
	
	public String getNcode() {
		if(code!=null){
			String _pre = code.substring(0, 2);
			if(Integer.parseInt(_pre)>40){
				return "1"+code;
			}else{
				return "0"+code;
			}
		}
		return code;
	}

	public void setNcode(String ncode) {
		this.ncode = ncode;
	}
	
	public String[] getZTJ(){
		String[] result = new String[2];
		if(this.zsp!=null){
			String ZTJ = "" + (Float.parseFloat(getZsp())*(1+10f/100));
			String DTJ = "" + (Float.parseFloat(getZsp())*(1-10f/100));
			result[0] = ZTJ;
			result[1] = DTJ;
		}
		return result;
	}

	@Override
	public int compareTo(StockInfo another) {  
		
		return another.getCode().compareTo(this.code);
		 
	}
}
